//
//  ZLZKTestViewController.m
//  ZLZKBaseUtils_Example
//
//  Created by sxh on 2020/12/9.
//  Copyright © 2020 1134548344@qq.com. All rights reserved.
//

#import "ZLZKTestViewController.h"
#import "ZLZKBaseBridge.h"
#import "SXHBaseScriptMessage.h"

@interface ZLZKTestViewController ()
<
    WKNavigationDelegate,
    SXHBaseScriptMessageDelegate
>
@property (nonatomic, strong) SXHBaseScriptMessage *scriptMessage;
@end

@implementation ZLZKTestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    SXHBaseWebView *web = [[SXHBaseWebView alloc] initWithFrame:self.view.bounds configuration:[WKWebViewConfiguration new]];
    web.delegate = self;
    web.sxhNavigationDelegate = self;

    
//    [self.view addSubview:web];
    
    web.params = @{
        @"name":@"李四",
        @"age": @(25),
        @"baseURL": @"http://www.baidu.com"
    }.mutableCopy;
    
//    [web loadingUrl:@"widget://helloBridge/index.html"];
//    [web loadingUrl:@"widget://worldBridge/index.html#/"];
    
    [self.view addSubview:web];
}

- (void)webView:(SXHBaseWebView *)webView didReceiveScriptMessage:(SXHBaseScriptMessage *)scriptMessage {
    
    NSLog(@"调用的函数名：%@ \n调用的参数列表：%@", scriptMessage.name, scriptMessage.userInfo);
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2000 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
//        [scriptMessage callbackWithRet:@{@"name": @"1111111111"}];
    });
}



@end
